﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.Enums;

namespace ZR.Model
{
    public class GetCodeModuleTreeListReq
    {
        /// <summary>
        /// 上级模块编码
        /// </summary>
        public string PaModuleCode { get; set; }

        /// <summary>
        /// 菜单类型编码
        /// </summary>
        public string MenuTypeCode { get; set; }

        [JsonIgnore]
        public MenuTypeEnum? MenuType
        {
            get
            {
                if(string.IsNullOrWhiteSpace(this.MenuTypeCode))
                {
                    return null;
                }
                MenuTypeEnum menuType;
                var isOk=Enum.TryParse(this.MenuTypeCode, true, out menuType);
                if(!isOk)
                {
                    return null;
                }
                isOk=Enum.IsDefined<MenuTypeEnum>(menuType);
                if (!isOk)
                {
                    return null;
                }
                return menuType;
            }
        }
    }
}
